package concurrent;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/8/9 10:10
 */

public class DeadLock {
    private static String A="A";
    private static String B="B";

    public static void main(String[] args) {

        List<Object> integers= Arrays.asList(1,2,3,4);
        List<String> as= integers.stream().map(Object::toString).collect(Collectors.toList());
        Set<String> aa=new HashSet<String>(as);

        String a="baiguan_1282";
        if(a.startsWith("baiguan_")){
        a=a.replaceAll("baiguan_","");}
        System.out.println(a);
        System.out.println(Integer.valueOf(a));

    }
    public static void main2(String[] args){
        Thread t1=new Thread(new Runnable() {
            public void run() {
                synchronized (A){
                    try {
                        Thread.sleep(2000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    synchronized (B){
                        System.out.println("1");
                    }
                }
            }
        });
        Thread t2=new Thread(new Runnable() {
            public void run() {
                synchronized (A){
                    synchronized (B){
                        System.out.println("2");
                    }
                }
            }
        });
        t1.start();
        t2.start();
    }
}
